import moment from 'moment';

export const generateNum = (begin, end) => {
  if (begin === '' || end === '') {
    return [];
  }
  let arr = [];
  for (let i = Number(begin); i <= Number(end); i++) {
    arr.push(i);
  }
  return arr;
};
export const TIME_ENUM = () => {
  const timeArr = new Array(96);
  let time = moment().startOf('date');
  const pointArray = [];
  _.forEach(timeArr, () => {
    time.add(15, 'minutes');
    const timeData = `${time.format('HHmm') === '0000' ? '2400' : time.format('HHmm')}`;
    pointArray.push(timeData);
  });
  return pointArray;
};

export const completeArr = () => {
  const dataTime = TIME_ENUM();
  return Array.from({ length: 96 }, (v, k) => {
    let isShow = (k + 1) % 4 === 0 || k === 0;
    return {
      id: k,
      unCheck: true,
      title: String(dataTime[k])?.substring(0, 2),
      showTitle: isShow,
    };
  });
};

export const RADIO_OBJ = {
  NINETYSIX: 'ninetysix',
  TWELVE: 'twelve',
  CUSTOM: 'Custom',
};

export const RADIO_ENUM = {
  [RADIO_OBJ.NINETYSIX]: { name: '96点' },
  [RADIO_OBJ.TWELVE]: { name: '24小时' },
  [RADIO_OBJ.CUSTOM]: { name: '自定义' },
};

export async function getData() {
  return new Promise((resolve) => {
    setTimeout(() => {
      const mock_data = Array.from({ length: 2 }, (v, k) => {
        return {
          key: String(k),
          name: k * 1 + 1,
          visable: false,
          begin: 10,
          end: 20,
          time: { key: k, begin: 10, end: 20 },
          caoozuo: '删除',
        };
      });
      mock_data[1].time = { ...mock_data[1].time, begin: 22, end: 25 };
      mock_data[1].begin = 22;
      mock_data[1].end = 25;
      const template = Array.from({ length: 2 }, (v, k) => {
        return {
          id: k,
          name: `模板名称${k + 1}`,
        };
      });
      resolve({ statusCode: '1000', dataList: mock_data, template });
    }, 500);
  });
}
